package com.dd.common.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dd.common.entity.SysUser;
import com.dd.common.vo.MenuVO;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
* @author cheng
* @description 针对表【c_sys_user(系统用户表)】的数据库操作Mapper
* @createDate 2025-08-23 17:00:07
* @Entity com.dd.common.entity.SysUser
*/
public interface SysUserMapper extends BaseMapper<SysUser> {

//    /**
//     * 根据用户ID查询其拥有的角色编码
//     */
//    @Select("SELECT r.role_code FROM c_sys_user_role ur INNER JOIN c_sys_role r ON ur.role_id = r.id WHERE ur.user_id = #{userId} AND ur.is_deleted = 0 AND r.status = 1 AND r.is_deleted = 0 ORDER BY r.sort ")
////    @Select("""
////    SELECT r.role_code
////    FROM c_sys_user_role ur
////    INNER JOIN c_sys_role r ON ur.role_id = r.id
////    WHERE ur.user_id = #{userId}
////      AND ur.is_deleted = 0
////      AND r.status = 1
////      AND r.is_deleted = 0
////    ORDER BY r.sort
////    """)
//    List<String> selectRoleCodesByUserId(@Param("userId") Long userId);

    /**
     * 根据用户ID查询其拥有的角色编码
     */
    List<String> selectRoleCodesByUserId(@Param("userId") Long userId);

    /**
     * 根据用户ID查询其拥有的权限标识（perms）
     */
    List<String> selectPermissionsByUserId(@Param("userId") Long userId);

    /**
     * 根据用户ID查询其可访问的菜单列表（只包含 menu_type=1,2 的目录和菜单）
     */
    List<MenuVO> selectMenuListByUserId(@Param("userId") Long userId);


}




